﻿<?php
require('configs/include.php');

class c_enviar_peticion extends super_controller {
    public function mostrarUsuario(){
        if(($this->get->username)!= ""){
        $cod['usuario']['username']=$this->get->username;
        $options['usuario']['lvl2'] = "one_perfil";
        $options['programador']['lvl2'] = "all";
        $components['usuario']['programador'] = array("u_p");
       
        $this->orm->connect();
        $this->orm->read_data(array("usuario", "programador"), $options, $cod);
        $usuario = $this->orm->get_objects("usuario", $components);
         $this->orm->close();
          $options2['calificacion']['lvl2']="countPoint";
         $cod2['calificacion']['username']=$this->get->username;
        $this->orm->connect();
        
        $this->orm->read_data(array("calificacion"), $options2, $cod2);
         $calificacion = $this->orm->get_objects("calificacion");
        $calificacion = count($calificacion);
        $this->orm->close();
         $this->engine->assign('calificacion', $calificacion);
        $this->engine->assign('usuario', $usuario);
        }
    }
    

    public function display() {

        $varAux = $this->gvar['n_index'] . " -> " . $this->gvar['n_request'];
        $this->engine->assign('ubicationPath', $varAux);
        $this->engine->display('header.tpl');
        $this->engine->display($this->temp_aux);     
        $this->engine->display('perfil.tpl');
        $this->engine->display('footer.tpl');
    }

    public function run() {
        if ($_SESSION['usuario'] != "") {
            try {
                if (isset($this->get->option)) {
                    $this->{$this->get->option}();
                }
            } catch (Exception $e) {
                $this->error = 1;
                $this->msg_warning = $e->getMessage();
                $this->img_warning = "incorrect.png";
                $this->engine->assign('type_warning', $this->type_warning);
                $this->engine->assign('msg_warning', $this->msg_warning);
                $this->engine->assign('img_warning', $this->img_warning);
                $this->temp_aux = 'message.tpl';
            }
            $this->display();
        } else {
            $this->engine->display('header.tpl');
            $this->engine->display('sinPermisos.tpl');
            $this->engine->display('footer.tpl');
        }
    }

}

$call = new c_enviar_peticion();
$call->run();
?>